/**操作文件**/
function viewBigEmpDetail(btn) {
    var uuid = $(btn).attr("data-id");
    if (uuid === undefined){$JuXue.n_danger("获取客户详情失败");return;}
    $("#customer_ids").val(uuid);
    /**发送请求**/
    $.post(ctx+"bigEpResoure/loadCustomerDetail",{},function (r) { //
        $("#myCustomer-modal").empty().append(r).modal('show').draggable();
    });
}
/**导出客户资料 确认**/
function exportCustomerInfoConfire() {
    $JuXue.confirmMsg({
        text: "请输入导出用途？",
        confirmButtonText: "确定导出"
    }, function(result) {
        if (result == ""){return "输入导出用途";}
        exportCustomerInfo(result);
    });
}

/**导出客户资料**/
function exportCustomerInfo(result) {
    /**记录导出的数据id**/
    var ids = $("#bigEmpTable").bootstrapTable("getSelections");
    var ids_arr = "";
    if (!ids.length) {$JuXue.n_warning("请勾选需要导出的客户信息！");return;}
    for (var i = 0; i < ids.length; i++) {
        ids_arr += ids[i].bpId;
        if (i !== (ids.length - 1)) ids_arr += ",";
    }
    /**选择导出的条件**/
    //导出批次
     var bpBatch = $("#bpBatch").val();
     //高校
    var collage = $("#collage-autocomplete").val();
    var academy   = $("#collagePref").find("option:selected").text();
    var collageZhuan = $("#collageZhuan").val();
    //意向等级选择
    var bpGroud = $("#bpGroud").val();
    var bpGroudStr = "";
    if(bpGroud!=null){
        bpGroudStr = bpGroud.join(",");
    }
    //导出次数
    var bpEpNum = $("#bpEpNum").val();
    var bpEpNumStr = "";
    if(bpEpNum!=null){
        bpEpNumStr = bpEpNum.join(",");
    }
    //大资源类型
    var bpResType = $("#bpResType").val();
    //初始意向
    var bpInteProject = $("#bpInteProject").val();
    //来源
    var bpSOurChanel = $("#bpSOurChanel").val();
    //时间
    var starttime = $("#starttime").val();
    var endtime = $("#endtime").val();
    // //专员
    var bpdirect = $("#bpdirect").val();
    var json = {
        exportMsg:result,
        bpBatch:bpBatch,
        bpColleges:collage,
        bpAcademy:academy,
        bpMajor:collageZhuan,
        bpGroud:bpGroudStr,
        bpEpNum:bpEpNumStr,
        bpResType:bpResType,
        bpInteProject:bpInteProject,
        bpSourChanel:bpSOurChanel,
        bpDirector:bpdirect,
        starttime:starttime,
        endtime:endtime,
        ids:ids_arr
    }

    $.post(ctx+"bigEpResoure/exportBigEmpDetail",json,function(r){
        if (r.code === 0) {$JuXue.n_success("导出记录生成,前往导出记录菜单导出");
        } else {$JuXue.n_warning(r.msg);}
    });
}
/**删除客户**/
function deleteCustomer() {
    /**记录导出的数据id**/
    var ids = $("#bigEmpTable").bootstrapTable("getSelections");
    var ids_arr = "";
    if (!ids.length) {$JuXue.n_warning("请勾选需要导出的客户信息！");return;}
    for (var i = 0; i < ids.length; i++) {
        ids_arr += ids[i].bpId;
        if (i !== (ids.length - 1)) ids_arr += ",";
    }
    $JuXue.confirm({
        text: "确定删除当前选择的客户？",
        confirmButtonText: "确定删除"
    }, function() {
        $.post(ctx+"bigEpResoure/bigempDeleteinfo",{ids:ids_arr},function(r){
            if (r.code === 0) {
                $JuXue.n_success(r.msg);
                $JuXue.refreshTable("bigEmpTable");
            } else {
                $JuXue.n_warning(r.msg);
            }
        });
    });
}
/**
 * 切换大资源类型
 * **/
function addMethod(btn) {
    $("#customeTrack").find("button").each(function () {$(this).removeClass("btn-primary");});
    $(btn).addClass("btn-primary");
    var type = $(btn).attr("data-click");
    $("#bpResType").val(type);
    //动态加载
    $JuXue.refreshTable("bigEmpTable");
}
/**
 * 切换意向项目
 * **/
function inteprojet(btn){
    $("#inteproject").find("button").each(function () {
        $(this).removeClass("btn-primary");
    });
    $(btn).addClass("btn-primary");
    //动态加载
    var project = $(btn).attr("data-click");
    $("#bpInteProject").val(project);
    //动态加载
    $JuXue.refreshTable("bigEmpTable");
}
/**切换来源渠道**/
function sourceChanel(btn){
    $("#sourceChanel").find("button").each(function () {
        $(this).removeClass("btn-primary");
    });
    $(btn).addClass("btn-primary");
    //动态加载
    var sourceChanel = $(btn).attr("data-click");
    $("#bpSOurChanel").val(sourceChanel);
    //动态加载
    $JuXue.refreshTable("bigEmpTable");
}
/**切换创建时间**/
function custTime(btn) {
    var data_cliak = $(btn).attr("data-click");
    if(data_cliak === "selft"){
        $("#advance-daterange").removeClass("hidden");
        $("#starttime").val(moment().subtract("days",29).format("YYYY-MM-DD"));
        $("#endtime").val(moment().format("YYYY-MM-DD"));
    }else{
        $("#advance-daterange").addClass("hidden");
        $("#starttime").val("");
        $("#endtime").val("");
    }
    $("#custTime").find("button").each(function () {
        $(this).removeClass("btn-primary");
    });
    $(btn).addClass("btn-primary");
    //动态加载
    $JuXue.refreshTable("bigEmpTable");
}

/**切换学院**/
function changeCollagePref(){
    var preform = $("#collagePref").val();
    var academy   = $("#collagePref").find("option:selected").text();
    $("#selectAcademy").val(academy);
    $.getJSON(ctx+"collage/getCollageByParentId",{"parentId":preform},function (r) {
        $("#collageZhuan").empty().append("<option value=\"\">请选择专业</option>");
        $.each(r,function (index,value) {
            $("#collageZhuan").append("<option value="+value.collageName+">"+value.collageName+"</option>");
        })
    });
    $JuXue.refreshTable("bigEmpTable");
}
/**切换专业**/
function changeMajor() {
    $JuXue.refreshTable("bigEmpTable");
}






